package com.demo.redis.controller;

import com.demo.redis.util.RedisUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zhou
 */
@RequestMapping("/redis")
@RestController
@Api(tags = "redis作业")
public class RedisController {

    @Resource
    RedisUtil redisUtil;

    @PostMapping("/setString")
    @ApiOperation("保存字符串到缓存")
    public boolean setString(String k, String v) {
        return redisUtil.set(k, v);
    }

    @GetMapping("getString")
    @ApiOperation("获取缓存字符串")
    public String getString(String k) {
        return redisUtil.get(k);
    }

}
